import request from '@/utils/request'

// 查询练习列表
export function listRandomPractice(query) {
  return request({
    url: '/exam/randomPractice/list',
    method: 'get',
    params: query
  })
}

// 查询练习所有列表
export function listAllRandomPractice(query) {
  return request({
    url: '/exam/randomPractice/listAll',
    method: 'get',
    params: query
  })
}

// 查询练习详细
export function getRandomPractice(practiceId) {
  return request({
    url: '/exam/randomPractice/getInfo/' + practiceId,
    method: 'get'
  })
}

// 新增练习
export function addRandomPractice(data) {
  return request({
    url: '/exam/randomPractice/add',
    method: 'post',
    data: data
  })
}

// 修改练习
export function updateRandomPractice(data) {
  return request({
    url: '/exam/randomPractice/edit',
    method: 'post',
    data: data
  })
}

// 删除练习
export function delRandomPractice(practiceId) {
  return request({
    url: '/exam/randomPractice/remove/' + practiceId,
    method: 'get'
  })
}

// 创建随机练习
export function createRandomPractice(data) {
  return request({
    url: '/exam/randomPractice/createRandomPractice',
    method: 'post',
    data: data
  })
}

// 检查是否有未完成的练习
export function checkUnfinishedPractice(bankId) {
  return request({
    url: '/exam/randomPractice/checkUnfinishedPractice',
    method: 'get',
    params: { bankId }
  })
}

// 获取随机练习的题目ID列表
export function getQuestionIds(practiceId) {
  return request({
    url: '/exam/randomPractice/getQuestionIds/' + practiceId,
    method: 'get'
  })
}

// 重新练习
export function restartPractice(data) {
  return request({
    url: '/exam/randomPractice/restartPractice',
    method: 'post',
    data: data
  })
}

// 获取随机练习题目详细信息
export function getPracticeQuestionDetail(practiceId, questionId) {
  return request({
    url: '/exam/randomPractice/getQuestionDetail/' + practiceId + '/' + questionId,
    method: 'get'
  })
}

// 提交随机练习答案
export function submitPracticeAnswer(data) {
  return request({
    url: '/exam/randomPractice/submitAnswer',
    method: 'post',
    data: data
  })
}

// 完成练习
export function completePractice(practiceId) {
  return request({
    url: '/exam/randomPractice/completePractice/' + practiceId,
    method: 'post'
  })
}